package com.hod.client.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.gears.client.database.DatabaseException;
import com.hod.client.backend.orm.client.GearsDataStore;
import com.hod.client.backend.orm.client.GearsQuery;

public class ClientRecordset {
	
	public static Client getClient(Integer idClient){
		try {
			GearsDataStore ds = (GearsDataStore) GWT.create(Client.class);
			Client o = (Client) ds.findById(idClient);
			return o;
		} catch (DatabaseException e) {
			// TODO Auto-generated catch block
			return null;
		} 
    } 
	
	public static Client[] getClients(){
		try {
			GearsDataStore ds = (GearsDataStore) GWT.create(Client.class);
			GearsQuery q = ds.getNamedQuery(Client.FIND_ALL);
			Client[] data = (Client[]) q.execute();
			//ds.close();
			return data;
		} catch (DatabaseException e) {
			// TODO Auto-generated catch block
			return null;
		} 
    } 

}
